#include <stdio.h>
#include "linkqueue.h"

void enter_queue (linkqueue lq);
void out_queue (linkqueue lq);

int main(int argc, char *argv[]){

    int flag;

    linkqueue lq = queue_create();
    if (lq == NULL)
	return -1;


    while (1) {

	printf("1-入队  2-出队  3-退出\n");
	scanf("%d", &flag);

	if (flag == 3)
	    break;

	switch (flag) {
	    case 1: enter_queue(lq);	
		    break;
	    case 2: out_queue(lq);
		    break;
	    case 3: break;
	    default: printf("请输入合法操作!\n");
		     break;	     
	}
    }

    queue_free(lq);
    return 0;
}

void enter_queue (linkqueue lq){

    printf("输入入队元素(仅限数字):");
    int value;
    scanf("%d", &value);
    enqueue(lq, value);

    queue_show(lq);
}

void out_queue (linkqueue lq){

    int num = dequeue(lq);
    if(num == -1)
	return;
    printf("出队的元素: %d\n", num);
    queue_show(lq);
}
